import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.StringJoiner;

import org.junit.Test;


public class JDBCTest {
	static String username = "root";
	static String password = "123456";
	static String url = "jdbc:mysql://localhost:3306/test2?characterEncoding=utf-8&amp;useUnicode=true";
	static String driver = "com.mysql.jdbc.Driver";

	private static Connection getConn() {
		try {
			Class.forName(driver);
			return DriverManager.getConnection(url, username, password);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Test
	public void exec() {
		Statement s = null;
		try {
			s =getConn().createStatement();
		} catch (SQLException e1) {
			e1.printStackTrace();
		}
		StringJoiner sql = new StringJoiner("");
		sql.add("insert user (username,password,addtime) values");
		long l = System.currentTimeMillis();
			try {
				for(int j = 0;j<140000;j++)
					sql.add("('asdf','123456',SYSDATE()),");
				
				String sq = sql.toString();
				s.execute(sq.substring(0,sq.length()-1));
				
			} catch (SQLException e) {
				e.printStackTrace();
			}
		System.out.println((System.currentTimeMillis()-l));
	}
}
